/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Core.CoreManager;
import DataAccess.ChiTietPhieuMuon;
import DataAccess.ChiTietPhieuTra;
import java.util.Vector;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author My PC
 */
public class ChiTietPhieuTraController extends CoreManager<ChiTietPhieuTra> {
    private String[] columnNames = {"Mã phiếu trả","Mã sách","Tình trạng sách","Số ngày quá hạn","Tiền đền"};
    public ChiTietPhieuTraController()
    { super();}
    @Override
    public void SetcolumnNames()
    {
        super.columnNames=columnNames;
    }
    public void showData(JTable table)
    {
        GetAllData("ChiTietPhieuTra");
        DefaultTableModel tableModel=new DefaultTableModel(columnNames, 0);
        table.setModel(tableModel);
       // int no=1;
        for(Object o: super.list)
        {
            ChiTietPhieuTra tg=(ChiTietPhieuTra)o;
            Vector oneRow=new Vector();
           oneRow.add(tg.getPhieuTraId());
            oneRow.add(tg.getSachId());
            oneRow.add(tg.getTinhTrangSach());
            oneRow.add(tg.getSoNgayQuaHan());
            oneRow.add(tg.getTienDen());
            tableModel.addRow(oneRow);
          //  System.out.println(tableModel.);
        }
    }
    public ChiTietPhieuTra getChiTietPhieuTraByIndex(int index)
    {
        return (ChiTietPhieuTra)list.get(index);
    }
    
      public int GetLastID()
    {
        if(list.size()!=0)
        return ((ChiTietPhieuTra)this.list.get(list.size()-1)).getCtptid();
        else return 0;
        
    }
}



